<?php
require_once '../includes/auth.php';
require_admin();

// 数据库操作部分
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    try {
        $stmt = $pdo->prepare("INSERT INTO countries 
            (iso_code, iso3_code, name_zh, name_en, phone_code) 
            VALUES (?, ?, ?, ?, ?)");

        $stmt->execute([
            $_POST['iso_code'],
            $_POST['iso3_code'],
            $_POST['name_zh'],
            $_POST['name_en'],
            $_POST['phone_code']
        ]);

        header('Location: index.php#countries');
    } catch (PDOException $e) {
        die("国家添加失败: " . $e->getMessage());
    }
}

// 显示部分整合到admin/index.php的countries区块